/*--------------------------------------------------------------------------
Copyright (c) 2014-2020 Runtronic 
All rights reserved.
V0.1
--------------------------------------------------------------------------*/

#ifndef __XC8F9463_H__
#define __XC8F9463_H__

///*CPU*/
sfr         SP        = 0x81;  //堆栈指针 
sfr         DPL0      = 0x82;  //数据指针0低8位
sfr         DPH0      = 0x83;  //数据指针0高8位
sfr         DPL1      = 0x84;  //数据指针1低8位
sfr         DPH1      = 0x85;  //数据指针1低8位
sfr         DPS       = 0x86;  //使用DPTR0/DPTR1寄存器选择位
sfr         P2        = 0xA0;  //P2读写寄存器

/* ------------------- 位寄存器-------------------- */
sfr         PSW       = 0xD0;  	//程序状态字
sbit        PSW_CY    = PSW^7;	//标志位		    0:加法运算最高位无进位，或者减法运算最高位无借位时		1:加法运算最高位有进位，或者减法运算最高位有借位时
sbit        PSW_AC    = PSW^6;	//进位辅助标志位	0:无借位、进位		1:加法运算时在bit3位有进位，或减法运算在bit3位有借位时
sbit        PSW_F0    = PSW^5;	//用户标志位
sbit        PSW_RS1   = PSW^4;	//工作寄存器组选择位
sbit        PSW_RS0   = PSW^3;	//工作寄存器组选择位
sbit        PSW_OV    = PSW^2;	//溢出标志位
sbit        PSW_F1    = PSW^1;	//F1标志
sbit        PSW_Parity= PSW^0;	//奇偶标志位		0:ACC中1的个数为偶数（包括0个）

sfr         ACC       = 0xE0;  //累加器A
sbit        ACC_7     = ACC^7;
sbit        ACC_6     = ACC^6;
sbit        ACC_5     = ACC^5;
sbit        ACC_4     = ACC^4;
sbit        ACC_3     = ACC^3;
sbit        ACC_2     = ACC^2;
sbit        ACC_1     = ACC^1;
sbit        ACC_0     = ACC^0;

sfr         B         = 0xF0;  //通用寄存器B

//----------------------总中断控制寄存器--------------------
sfr         IE        = 0xA8;  //系统中断控制寄存器
sbit        IE_EA     = IE^7;  //CPU总中断开关允许位



//----------------------与省电模式和看门狗相关寄存器--------------------
#define SLPTIM_BASE 0x88

sfr      SLPTIM_CR    = 0x88;        //睡眠计数器控制寄存器
sbit	 SLPIE		  = SLPTIM_CR^7; //睡眠定时器中断使能位
sbit	 WDTEN		  = SLPTIM_CR^5; //看门狗定时器使能
sbit	 X32K_SEL	  = SLPTIM_CR^4; //32K时钟源选择
sbit     SLEEPDIS	  = SLPTIM_CR^3; //睡眠定时器使能

sfr      SLPTIM_SR    = 0x89;  //睡眠计数寄存器
sfr      SLPTIM_CLR   = 0x8A;  //看门狗清除寄存器
sfr      SLPTIM_WDT   = 0x8B;  //看门狗计数器状态寄存器
sfr      SLPTIM_CNTL  = 0x8C;  //睡眠计数器计数值低8位寄存器
sfr      SLPTIM_CNTH  = 0x8D;  //睡眠计数器计数值高8位寄存器
sfr      SLPTIM_PRDRL = 0x8E;  //睡眠计数器预分频低8位
sfr      SLPTIM_PRDRH = 0x8F;  //睡眠计数器预分频高8位
sfr16    SLPTIM_PRDR  = 0x8E;

//-----------------------系统模式控制寄存器-------------------
sfr      SCR_CFG      = 0x91;  //系统配置寄存器
sfr      SCR_SLEEP    = 0x92;  //休眠寄存器
sfr      SCR_CALI     = 0x93;  //校准寄存器	

//------------------------与中断相关寄存器------------------
sfr      INT_MSK0     = 0xAA;  //中断屏蔽寄存器0
sfr      INT_MSK1     = 0xAB;  //中断屏蔽寄存器1
sfr      INT_MSK2     = 0xAC;  //中断屏蔽寄存器2
sfr      INT_PRI0     = 0xAD;  //中断优先级配置寄存器0
sfr      INT_PRI1     = 0xAE;  //中断优先级配置寄存器1 
sfr      INT_PRI2     = 0xAF;  //中断优先级配置寄存器2

//-----------------------与时钟相关寄存器-------------------
sfr      CLK_CR       = 0x94;  //系统时钟控制寄存器
sfr      PCLK_CR      = 0x95;  //外设时钟控制寄存器
sfr      PCLK_DIV12   = 0x96;  //SCK1\SCK2时钟控制寄存器
sfr      PCLK_DIV3    = 0x97;  //SCK3时钟控制寄存器

//------------------------与TIMER0相关寄存器------------------
sfr      TIM0_CR      = 0xF8;  //TIMER0控制寄存器
sfr      TIM0_CNTR    = 0xF9;  //TIMER0计数值寄存器
sfr      TIM0_ARR     = 0xFA;  //TIMER0自动重装寄存器
sfr      TIM0_IE      = 0xFB;  //TIMER0中断控制寄存器
sfr      TIM0_SR      = 0xFC;  //TIMER0状态寄存器
sfr      SSCONR       = 0xFD;  //TIMER1/2软件同步控制寄存器

//------------------------与TIMER1相关寄存器------------------
sfr      TIM1_CR      = 0xC0;  //TIMER1控制寄存器
sfr      TIM1_IE      = 0xC1;  //TIMER1中断控制寄存器
sfr      TIM1_SR      = 0xC2;  //TIMER1状态寄存器
sfr      TIM1_PR      = 0xC3;  //TIMER1密码寄存器

//------------------------与TIMER2相关寄存器------------------
sfr      TIM2_CR      = 0xC8;  //TIMER2控制寄存器
sfr      TIM2_IE      = 0xC9;  //TIMER2中断控制寄存器
sfr      TIM2_SR      = 0xCA;  //TIMER2状态寄存器
sfr      TIM2_PR      = 0xCB;  //TIMER2密码寄存器

//------------------------与TIMER3相关寄存器------------------
sfr   	TIM3_CR       = 0xCC;  //TIMER3控制寄存器
sfr   	TIM3_IE       = 0xCD;  //TIMER3中断控制寄存器
sfr   	TIM3_SR       = 0xCE;  //TIMER3状态寄存器
sfr   	TIM3_PR       = 0xCF;  //TIMER3密码寄存器

//------------------------与I2C相关寄存器------------------
sfr      I2C_ADDR     = 0xA1;  //I2C从机地址寄存器  
sfr      I2C_CR       = 0xA2;  //I2C控制寄存器
sfr      I2C_STAT     = 0xA3;  //I2C状态寄存器
sfr      I2C_DR       = 0xA4;  //I2C数据寄存器
sfr      I2C_MCR      = 0xA5;  //I2C主机控制寄存器

//------------------------与UART0相关寄存器------------------
sfr      UART0_DR     = 0x9C;  //UART0数据寄存器
sfr      UART0_CR     = 0x9D;  //UART0控制寄存器
sfr      UART0_SR     = 0x9E;  //UART0状态寄存器
sfr      UART0_CFG    = 0x9F;  //UART0配置寄存器

//------------------------与UART1相关寄存器------------------
sfr      UART1_DR     = 0xBC;  //UART1数据寄存器
sfr      UART1_CR     = 0xBD;  //UART1控制寄存器
sfr      UART1_SR     = 0xBE;  //UART1状态寄存器
sfr      UART1_CFG    = 0xBF;  //UART1配置寄存器

//------------------------与ADC相关寄存器------------------
sfr      ADC_CR0      = 0xE8;  //ADC转换控制寄存器0
sfr      ADC_CR1      = 0xE9;  //ADC转换控制寄存器1
sfr      ADC_CR2      = 0xEA;  //ADC转换控制寄存器2
sfr      ADC_CHSEL    = 0xEB;  //ADC模拟量输入通道选择寄存器
sfr      ADC_CON      = 0xEC;  //ADC配置寄存器
sfr      ADC_DLY      = 0xED;  //ADC延迟配置寄存器
sfr      ADC_RESL     = 0xEE;  //ADC转换结果低4位寄存器
sfr      ADC_RESH     = 0xEF;  //ADC转换结果高8位寄存器
sfr      ADC_COMPL    = 0xFE;  //ADC比较值低4位寄存器
sfr      ADC_COMPH    = 0xFF;  //ADC比较值高8位寄存器

//-------------------------与模拟比较器相关寄存器-----------------
sfr   	AC0_CR1       = 0xE1;  //模拟比较器0控制寄存器1
sfr   	AC0_CR2       = 0xE2;  //模拟比较器0控制寄存器2
sfr  	AC1_CR1       = 0xE4;  //模拟比较器1控制寄存器1
sfr   	AC1_CR2       = 0xE5;  //模拟比较器1控制寄存器2

//-------------------------与SPI相关寄存器-----------------
sfr   	SPI_SHIFTER   = 0xF1;  //SPI移位寄存器
sfr   	SPI_DR        = 0xF2;  //SPI数据寄存器
sfr   	SPI_CR        = 0xF3;  //SPI控制寄存器
sfr   	SPI_STAT      = 0xF4;  //SPI状态寄存器
sfr   	SPI_CR2       = 0xF5;  //SPI突发控制寄存器
sfr   	SPI_WRADDR    = 0xF6;  //SPI突发地址寄存器

//------------------------与GPIO相关寄存器------------------
sfr      P0_DR        = 0x98;  //端口P0数据寄存器
//------------P00/P01/P02/P03/P04/P05/P06/P07-------------------
sbit     P0_0         = P0_DR^0;  
sbit     P0_1         = P0_DR^1;  
sbit     P0_2         = P0_DR^2; 
sbit     P0_3         = P0_DR^3;  
sbit     P0_4         = P0_DR^4;  
sbit     P0_5         = P0_DR^5; 
sbit     P0_6         = P0_DR^6;  
sbit     P0_7         = P0_DR^7; 

sfr      P0_DM0       = 0x99;  //端口P0模式0位寄存器
sfr      P0_DM1       = 0x9A;  //端口P0模式1位寄存器

sfr      P1_DR        = 0xB0;  //端口P1数据寄存器
//------------P10/P11/P12/P13/P14/P15/P16/P17-------------------
sbit     P1_0         = P1_DR^0; 
sbit     P1_1         = P1_DR^1;  
sbit     P1_2         = P1_DR^2;  
sbit     P1_3         = P1_DR^3; 
sbit     P1_4         = P1_DR^4;  
sbit     P1_5         = P1_DR^5;  
sbit     P1_6         = P1_DR^6;  
sbit     P1_7         = P1_DR^7;  

sfr      P1_DM0       = 0xB1;  //端口P1模式0位寄存器
sfr      P1_DM1       = 0xB2;  //端口P1模式1位寄存器

sfr      P2_DR        = 0xB8;  //端口P2数据寄存器
//------------P20/P21/P22/P23/P24/P25/P26/P27-------------------------------------
sbit     P2_0         = P2_DR^0;  
sbit     P2_1         = P2_DR^1; 
sbit     P2_2         = P2_DR^2; 
sbit     P2_3         = P2_DR^3; 
sbit     P2_4         = P2_DR^4; 
sbit     P2_5         = P2_DR^5; 
sbit     P2_6         = P2_DR^6; 
sbit     P2_7         = P2_DR^7; 



sfr      P2_DM0       = 0xB9;  //端口P2模式0位寄存器
sfr      P2_DM1       = 0xBA;  //端口P2模式1位寄存器

sfr      P3_DR        = 0xD8;  //端口P2数据寄存器
//------------P30/P31-------------------------------------------------------------
sbit     P3_0         = P3_DR^0;  
sbit     P3_1         = P3_DR^1; 

sfr      P3_DM0       = 0xD9;  //端口P3模式0位寄存器
sfr      P3_DM1       = 0xDA;  //端口P3模式1位寄存器


//------------------------与TIMER1相关寄存器------------------ 
#define TIM1_CR_BASE 0xFF50
#define TIM1_FCONR    *(unsigned char volatile xdata *)(TIM1_CR_BASE)     //TIMER1时钟控制寄存器  
#define TIM1_VPERR    *(unsigned char volatile xdata *)(TIM1_CR_BASE+0x1) //TIMER1周期间隔响应控制寄存器
#define TIM1_DTUA     *(unsigned char volatile xdata *)(TIM1_CR_BASE+0x2) //TIMER1死区时间控制寄存器
#define TIM1_BRAKE    *(unsigned char volatile xdata *)(TIM1_CR_BASE+0x3) //TIMER1刹车控制寄存器
#define TIM1_DTR      *(unsigned char volatile xdata *)(TIM1_CR_BASE+0x4) //TIMER1死区控制寄存器
#define TIM1_PCONRA   *(unsigned char volatile xdata *)(TIM1_CR_BASE+0x5) //TIMER1端口A控制寄存器
#define TIM1_PCONRB   *(unsigned char volatile xdata *)(TIM1_CR_BASE+0x6) //TIMER1端口B控制寄存器
#define TIM1_CNTL     *(unsigned char volatile xdata *)(TIM1_CR_BASE+0x8) //TIMER1计数值低8位寄存器
#define TIM1_CNTH     *(unsigned char volatile xdata *)(TIM1_CR_BASE+0x9) //TIMER1计数值高8位寄存器
#define TIM1_ARRL     *(unsigned char volatile xdata *)(TIM1_CR_BASE+0xA) //TIMER1自动重载低8位寄存器
#define TIM1_ARRH     *(unsigned char volatile xdata *)(TIM1_CR_BASE+0xB) //TIMER1自动重载高8位寄存器
#define TIM1_GCMARL   *(unsigned char volatile xdata *)(TIM1_CR_BASE+0xC) //TIMER1比较捕获A低8位寄存器
#define TIM1_GCMARH   *(unsigned char volatile xdata *)(TIM1_CR_BASE+0xD) //TIMER1比较捕获A高8位寄存器
#define TIM1_GCMBRL   *(unsigned char volatile xdata *)(TIM1_CR_BASE+0xE) //TIMER1比较捕获B低8位寄存器
#define TIM1_GCMBRH   *(unsigned char volatile xdata *)(TIM1_CR_BASE+0xF) //TIMER1比较捕获B高8位寄存器

//------------------------与TIMER2相关寄存器------------------ 
#define TIM2_CR_BASE 0xFF60
#define TIM2_FCONR    *(unsigned char volatile xdata *)(TIM2_CR_BASE)     //TIMER2时钟控制寄存器 
#define TIM2_VPERR    *(unsigned char volatile xdata *)(TIM2_CR_BASE+0x1) //TIMER2周期间隔响应控制寄存器
#define TIM2_DTUA     *(unsigned char volatile xdata *)(TIM2_CR_BASE+0x2) //TIMER2死区时间控制寄存器
#define TIM2_BRAKE    *(unsigned char volatile xdata *)(TIM2_CR_BASE+0x3) //TIMER2刹车控制寄存器
#define TIM2_DTR      *(unsigned char volatile xdata *)(TIM2_CR_BASE+0x4) //TIMER2死区控制寄存器
#define TIM2_PCONRA   *(unsigned char volatile xdata *)(TIM2_CR_BASE+0x5) //TIMER2端口A控制寄存器
#define TIM2_PCONRB   *(unsigned char volatile xdata *)(TIM2_CR_BASE+0x6) //TIMER2端口B控制寄存器
#define TIM2_CNTL     *(unsigned char volatile xdata *)(TIM2_CR_BASE+0x8) //TIMER2计数值低8位寄存器
#define TIM2_CNTH     *(unsigned char volatile xdata *)(TIM2_CR_BASE+0x9) //TIMER2计数值高8位寄存器
#define TIM2_ARRL     *(unsigned char volatile xdata *)(TIM2_CR_BASE+0xA) //TIMER2自动重载低8位寄存器
#define TIM2_ARRH     *(unsigned char volatile xdata *)(TIM2_CR_BASE+0xB) //TIMER2自动重载高8位寄存器
#define TIM2_GCMARL   *(unsigned char volatile xdata *)(TIM2_CR_BASE+0xC) //TIMER2比较捕获A低8位寄存器
#define TIM2_GCMARH   *(unsigned char volatile xdata *)(TIM2_CR_BASE+0xD) //TIMER2比较捕获A高8位寄存器
#define TIM2_GCMBRL   *(unsigned char volatile xdata *)(TIM2_CR_BASE+0xE) //TIMER2比较捕获B低8位寄存器
#define TIM2_GCMBRH   *(unsigned char volatile xdata *)(TIM2_CR_BASE+0xF) //TIMER2比较捕获B高8位寄存器
 
//------------------------与TIMER3相关寄存器------------------  
#define TIM3_CR_BASE 0xFF70
#define TIM3_FCONR    *(unsigned char volatile xdata *)(TIM3_CR_BASE)     //TIMER3时钟控制寄存器 
#define TIM3_VPERR    *(unsigned char volatile xdata *)(TIM3_CR_BASE+0x1) //TIMER3周期间隔响应控制寄存器
#define TIM3_DTUA     *(unsigned char volatile xdata *)(TIM3_CR_BASE+0x2) //TIMER3死区时间控制寄存器
#define TIM3_BRAKE    *(unsigned char volatile xdata *)(TIM3_CR_BASE+0x3) //TIMER3刹车控制寄存器
#define TIM3_DTR      *(unsigned char volatile xdata *)(TIM3_CR_BASE+0x4) //TIMER3死区控制寄存器
#define TIM3_PCONRA   *(unsigned char volatile xdata *)(TIM3_CR_BASE+0x5) //TIMER3端口A控制寄存器
#define TIM3_PCONRB   *(unsigned char volatile xdata *)(TIM3_CR_BASE+0x6) //TIMER3端口B控制寄存器
#define TIM3_CNTL     *(unsigned char volatile xdata *)(TIM3_CR_BASE+0x8) //TIMER3计数值低8位寄存器
#define TIM3_CNTH     *(unsigned char volatile xdata *)(TIM3_CR_BASE+0x9) //TIMER3计数值高8位寄存器
#define TIM3_ARRL     *(unsigned char volatile xdata *)(TIM3_CR_BASE+0xA) //TIMER3自动重载低8位寄存器
#define TIM3_ARRH     *(unsigned char volatile xdata *)(TIM3_CR_BASE+0xB) //TIMER3自动重载高8位寄存器
#define TIM3_GCMARL   *(unsigned char volatile xdata *)(TIM3_CR_BASE+0xC) //TIMER3比较捕获A低8位寄存器
#define TIM3_GCMARH   *(unsigned char volatile xdata *)(TIM3_CR_BASE+0xD) //TIMER3比较捕获A高8位寄存器
#define TIM3_GCMBRL   *(unsigned char volatile xdata *)(TIM3_CR_BASE+0xE) //TIMER3比较捕获B低8位寄存器
#define TIM3_GCMBRH   *(unsigned char volatile xdata *)(TIM3_CR_BASE+0xF) //TIMER3比较捕获B高8位寄存器 

//------------------------与FLASH控制器相关寄存器-------------
#define MTP_CR_BASE 0xFF00
#define FLASH_CR      *(unsigned char volatile xdata *)(MTP_CR_BASE)       //FLASH 控制寄存器
#define FLASH_CFG     *(unsigned char volatile xdata *)(MTP_CR_BASE+0x1)   //FLASH配置寄存器
#define FLASH_KEY     *(unsigned char volatile xdata *)(MTP_CR_BASE+0x2)   //FLASH KEY寄存器
#define FLASH_ADL     *(unsigned char volatile xdata *)(MTP_CR_BASE+0x3)   //FLASH编程地址低8位
#define FLASH_ADH     *(unsigned char volatile xdata *)(MTP_CR_BASE+0x4)   //FLASH编程地址高6位
#define FLASH_PBUFL   *(unsigned char volatile xdata *)(MTP_CR_BASE+0x5)   //FLASH编程缓冲地址低8位
#define FLASH_PBUFH   *(unsigned char volatile xdata *)(MTP_CR_BASE+0x6)   //FLASH编程缓冲地址高2位
#define FLASH_DR      *(unsigned char volatile xdata *)(MTP_CR_BASE+0x7)   //FLASH读数据寄存器

//------------------------与GPIO相关寄存器------------------ 
#define PT_SEL0       *(unsigned char volatile xdata *)(0xFF10)            //端口位置配置寄存器  
#define PT_SEL1       *(unsigned char volatile xdata *)(0xFF11)            //端口位置配置寄存器 
#define PERP0_EN      *(unsigned char volatile xdata *)(0xFF18)            //外设管脚位置使能配置寄存器0    
#define PERP1_EN      *(unsigned char volatile xdata *)(0xFF19)            //外设管脚位置使能配置寄存器1    
#define PERP2_EN      *(unsigned char volatile xdata *)(0xFF1A)            //外设管脚位置使能配置寄存器2 

#define P0_BASE	0xFF20
#define P0_FLAG    	  *(unsigned char volatile xdata *)(P0_BASE+0x0)        //端口P0中断标志位寄存器    
#define P0_GE         *(unsigned char volatile xdata *)(P0_BASE+0x1) 		//端口P0数字复用使能寄存器   
#define P0_PU         *(unsigned char volatile xdata *)(P0_BASE+0x3)        //端口P0上拉控制寄存器   
#define P0_PD         *(unsigned char volatile xdata *)(P0_BASE+0x4)        //端口P0下拉控制寄存器   
#define P0_IE         *(unsigned char volatile xdata *)(P0_BASE+0x5)        //端口P0中断使能寄存器   
#define P0_IC0        *(unsigned char volatile xdata *)(P0_BASE+0x6)        //端口P0中断控制0位寄存器  
#define P0_IC1        *(unsigned char volatile xdata *)(P0_BASE+0x7)        //端口P0中断控制1位寄存器   

#define P1_BASE	0xFF30
#define P1_FLAG      *(unsigned char volatile xdata *)(P1_BASE+0x0) 		//端口P1中断标志位寄存器    
#define P1_GE        *(unsigned char volatile xdata *)(P1_BASE+0x1) 		//端口P1数字复用使能寄存器  
#define P1_PU        *(unsigned char volatile xdata *)(P1_BASE+0x3) 		//端口P1上拉控制寄存器   
#define P1_PD        *(unsigned char volatile xdata *)(P1_BASE+0x4) 		//端口P1下拉控制寄存器    
#define P1_IE        *(unsigned char volatile xdata *)(P1_BASE+0x5) 		//端口P1中断使能寄存器  
#define P1_IC0       *(unsigned char volatile xdata *)(P1_BASE+0x6) 		//端口P1中断控制0位寄存器  
#define P1_IC1       *(unsigned char volatile xdata *)(P1_BASE+0x7) 		//端口P1中断控制1位寄存器  

#define P2_BASE	0xFF40
#define P2_FLAG      *(unsigned char volatile xdata *)(P2_BASE+0x0) 		//端口P2中断标志位寄存器   
#define P2_GE        *(unsigned char volatile xdata *)(P2_BASE+0x1) 		//端口P2数字复用使能寄存器   
#define P2_PU        *(unsigned char volatile xdata *)(P2_BASE+0x3) 		//端口P2上拉控制寄存器    
#define P2_PD        *(unsigned char volatile xdata *)(P2_BASE+0x4) 		//端口P2下拉控制寄存器  
#define P2_IE        *(unsigned char volatile xdata *)(P2_BASE+0x5) 		//端口P2中断使能寄存器  
#define P2_IC0       *(unsigned char volatile xdata *)(P2_BASE+0x6) 		//端口P2中断控制0位寄存器   
#define P2_IC1       *(unsigned char volatile xdata *)(P2_BASE+0x7) 		//端口P2中断控制1位寄存器   

#define P3_BASE	0xFFC0
#define P3_FLAG      *(unsigned char volatile xdata *)(P3_BASE+0x0) 		//端口P2中断标志位寄存器     
#define P3_GE        *(unsigned char volatile xdata *)(P3_BASE+0x1) 		//端口P2数字复用使能寄存器  
#define P3_PU        *(unsigned char volatile xdata *)(P3_BASE+0x3) 		//端口P2上拉控制寄存器  
#define P3_PD        *(unsigned char volatile xdata *)(P3_BASE+0x4) 		//端口P2下拉控制寄存器  
#define P3_IE        *(unsigned char volatile xdata *)(P3_BASE+0x5) 		//端口P2中断使能寄存器  
#define P3_IC0       *(unsigned char volatile xdata *)(P3_BASE+0x6) 		//端口P2中断控制0位寄存器 
#define P3_IC1       *(unsigned char volatile xdata *)(P3_BASE+0x7) 		//端口P2中断控制1位寄存器

//-------------------------模拟控制寄存器------------------------
#define ANA_BASE	0xFF80
#define BG_CR        *(unsigned char volatile xdata *)(ANA_BASE)     		//Bandgap使能寄存器
#define BG_VTRIM     *(unsigned char volatile xdata *)(ANA_BASE+0x1)
#define BG_ITRIM     *(unsigned char volatile xdata *)(ANA_BASE+0x2)
#define BG_TCTRIM    *(unsigned char volatile xdata *)(ANA_BASE+0x3)
#define BG_TEST      *(unsigned char volatile xdata *)(ANA_BASE+0x4)
#define BORLVD_CR    *(unsigned char volatile xdata *)(ANA_BASE+0x5)  		//BORLVD控制寄存器
#define BORLVD_STAT  *(unsigned char volatile xdata *)(ANA_BASE+0x6)   		//BORLVD状态寄存器
#define ANA_TEST     *(unsigned char volatile xdata *)(ANA_BASE+0x7)
#define IMO_CR       *(unsigned char volatile xdata *)(ANA_BASE+0x8)   		//IMO控制寄存器
#define IMO_TRIM     *(unsigned char volatile xdata *)(ANA_BASE+0x9)
#define ILO_TRIM     *(unsigned char volatile xdata *)(ANA_BASE+0xA)
#define ILO_TEST     *(unsigned char volatile xdata *)(ANA_BASE+0xB)
#define IMO_TRIMH    *(unsigned char volatile xdata *)(ANA_BASE+0xC)
#define XTAL_CR      *(unsigned char volatile xdata *)(ANA_BASE+0xD)   		//XTAL控制寄存器
#define MBIST_KEY    *(unsigned char volatile xdata *)(ANA_BASE+0xE)
#define SRAM_DVS     *(unsigned char volatile xdata *)(ANA_BASE+0xF)

//--------------------------模拟比较器控制寄存器--------------------
#define CMP_BASE 0xFF90
#define DAC_BUFCR1    *(unsigned char volatile xdata *)(CMP_BASE+0x7)      //OFFSET修调配置寄存器1
#define DAC_BUFCR2    *(unsigned char volatile xdata *)(CMP_BASE+0xE)      //OFFSET修调配置寄存器2

//---------------------------LED/LCD控制寄存器----------------------
#define DISP_BASE 0xFFA0
#define DISP_CR       *(unsigned char volatile xdata *)(DISP_BASE+0x0) 		//显示功能配置寄存器
#define DISP_DIVH     *(unsigned char volatile xdata *)(DISP_BASE+0x1) 		//时钟分频系数高位配置寄存器
#define DISP_DIVL     *(unsigned char volatile xdata *)(DISP_BASE+0x2) 		//时钟分频系数低位配置寄存器
#define DISP_SEGL     *(unsigned char volatile xdata *)(DISP_BASE+0x3) 		//SEG输出管脚配置寄存器的低8位
#define DISP_SEGH     *(unsigned char volatile xdata *)(DISP_BASE+0x4) 		//SEG输出管脚配置寄存器的高4位
#define DISP_COM      *(unsigned char volatile xdata *)(DISP_BASE+0x5) 		//COM输出管脚配置寄存器
#define LCD_CFG0      *(unsigned char volatile xdata *)(DISP_BASE+0x6) 		//LCD对比度配置寄存器
#define LCD_CFG1      *(unsigned char volatile xdata *)(DISP_BASE+0x7) 		//LCD驱动模式配置寄存器
#define DISP_DATA1    *(unsigned char volatile xdata *)(DISP_BASE+0x8) 		//LED/LCD段码显示配置寄存器
#define DISP_DATA2    *(unsigned char volatile xdata *)(DISP_BASE+0x9) 		//LED/LCD段码显示配置寄存器
#define DISP_DATA3    *(unsigned char volatile xdata *)(DISP_BASE+0xa) 		//LED/LCD段码显示配置寄存器
#define DISP_DATA4    *(unsigned char volatile xdata *)(DISP_BASE+0xb) 		//LED/LCD段码显示配置寄存器
#define DISP_DATA5    *(unsigned char volatile xdata *)(DISP_BASE+0xc) 		//LED/LCD段码显示配置寄存器
#define DISP_DATA6    *(unsigned char volatile xdata *)(DISP_BASE+0xd) 		//LED/LCD段码显示配置寄存器
#define DISP_DATA7    *(unsigned char volatile xdata *)(DISP_BASE+0xe) 		//LED/LCD段码显示配置寄存器
#define DISP_DATA8    *(unsigned char volatile xdata *)(DISP_BASE+0xf) 		//LED/LCD段码显示配置寄存器
#define DISP_DATA9    *(unsigned char volatile xdata *)(DISP_BASE+0x10) 	//LED/LCD段码显示配置寄存器
#define DISP_DATA10   *(unsigned char volatile xdata *)(DISP_BASE+0x11) 	//LED/LCD段码显示配置寄存器
#define DISP_DATA11   *(unsigned char volatile xdata *)(DISP_BASE+0x12) 	//LED/LCD段码显示配置寄存器
#define DISP_DATA12   *(unsigned char volatile xdata *)(DISP_BASE+0x13) 	//LED/LCD段码显示配置寄存器
#define COM_SINK      *(unsigned char volatile xdata *)(DISP_BASE+0x14) 	//COM口灌电流能力配置寄存器
#define SEG_DRIV_L    *(unsigned char volatile xdata *)(DISP_BASE+0x15) 	//SEG口驱动能力配置寄存器
#define SEG_DRIV_H    *(unsigned char volatile xdata *)(DISP_BASE+0x16) 	//SEG口驱动能力配置寄存器
//-------------------------------------------------

typedef unsigned char 		   u8;  
typedef unsigned short 		   u16;
typedef unsigned long 		   u32;

#endif
